package org.xq.demo.mvc;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@RestController
public class DemoController {

    @GetMapping("hello")
    public Object hello(HttpServletRequest request) {
        Map<String, Object> result = new HashMap<>();
        result.put("code", 100);
        result.put("host", request.getServerName());
        result.put("port", request.getServerPort());
        result.put("msg", "Good Morning!");
        return result;
    }
}
